package com.nsi.o2o.util;

import com.google.code.kaptcha.Constants;

import javax.servlet.http.HttpServletRequest;

/**
 * @author: Luo Zhen
 * @date: 2018/9/11 10:00
 * @description:
 */
public class CodeUtil {

    public static boolean checkVerifyCode(HttpServletRequest request) {
        //当前会话的验证码
        String verifyCodeExpected = (String) request.getSession().getAttribute(
                Constants.KAPTCHA_SESSION_KEY
        );
        String verifyCodeActual = HttpServletRequestUtil.getString(request, "verifyCodeActual");
        if (verifyCodeActual == null || verifyCodeActual.equals(verifyCodeExpected)) {
            return false;
        }
        return true;
    }
}
